<a href='https://github.com/angular/angular.js/edit/v1.6.x/src/ng/templateRequest.js?message=docs($templateRequest)%3A%20describe%20your%20change...#L41' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit">&nbsp;</i>Improve this Doc</a>



<a href='https://github.com/angular/angular.js/tree/v1.6.6/src/ng/templateRequest.js#L41' class='view-source pull-right btn btn-primary'>
  <i class="glyphicon glyphicon-zoom-in">&nbsp;</i>View Source
</a>


<header class="api-profile-header">
  <h1 class="api-profile-header-heading">$templateRequest</h1>
  <ol class="api-profile-header-structure naked-list step-list">
    
  <li>
    <a href="api/ng/provider/$templateRequestProvider">- $templateRequestProvider</a>
  </li>

    <li>
      - service in module <a href="api/ng">ng</a>
    </li>
  </ol>
</header>





<div class="api-profile-description">
  <p>The <code>$templateRequest</code> service runs security checks then downloads the provided template using
<code>$http</code> and, upon success, stores the contents inside of <code>$templateCache</code>. If the HTTP request
fails or the response data of the HTTP request is empty, a <code>$compile</code> error will be thrown (the
exception can be thwarted by setting the 2nd parameter of the function to true). Note that the
contents of <code>$templateCache</code> are trusted, so the call to <code>$sce.getTrustedUrl(tpl)</code> is omitted
when <code>tpl</code> is of type string and <code>$templateCache</code> has the matching entry.</p>
<p>If you want to pass custom options to the <code>$http</code> service, such as setting the Accept header you
can configure this via <a href="api/ng/provider/$templateRequestProvider#httpOptions"><code>$templateRequestProvider</code></a>.</p>

</div>




<div>
  

  

  <h2 id="usage">Usage</h2>
    
      <p><code>$templateRequest(tpl, [ignoreRequestError]);</code></p>


    

    
<section class="api-section">
  <h3>Arguments</h3>

<table class="variables-matrix input-arguments">
  <thead>
    <tr>
      <th>Param</th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    
    <tr>
      <td>
        tpl
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-string">string</a><a href="" class="label type-hint type-hint-trustedresourceurl">TrustedResourceUrl</a>
      </td>
      <td>
        <p>The HTTP request template URL</p>

        
      </td>
    </tr>
    
    <tr>
      <td>
        ignoreRequestError
        
        <div><em>(optional)</em></div>
      </td>
      <td>
        <a href="" class="label type-hint type-hint-boolean">boolean</a>
      </td>
      <td>
        <p>Whether or not to ignore the exception when the request fails or the template is empty</p>

        
      </td>
    </tr>
    
  </tbody>
</table>

</section>
    
    <h3>Returns</h3>
<table class="variables-matrix return-arguments">
  <tr>
    <td><a href="" class="label type-hint type-hint-promise">Promise</a></td>
    <td><p>a promise for the HTTP response data of the given URL.</p>
</td>
  </tr>
</table>

  
  
  
<h2>Properties</h2>
<ul class="properties">
  <li id="totalPendingRequests">
    <h3><code>totalPendingRequests</code></h3>
    <table class="variables-matrix return-arguments">
  <tr>
    <td><a href="" class="label type-hint type-hint-number">number</a></td>
    <td><p>total amount of pending template requests being downloaded.</p>
</td>
  </tr>
</table>
    
  </li>
  </ul>



  
</div>


